package com.hitqz.robot.biz.controller;

import com.hitqz.robot.api.business.enums.VoiceEnum;
import com.hitqz.robot.biz.core.FileProperties;
import com.hitqz.robot.camera.EquipmentFactory;
import com.hitqz.robot.camera.IEquipmentService;
import com.hitqz.robot.camera.configure.EquipmentCmdEnum;
import com.hitqz.robot.camera.dto.QueryParamsDto;
import com.hitqz.robot.camera.dto.VoicePlayDto;
import com.hitqz.robot.common.core.util.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping(value = "camera")
@RequiredArgsConstructor
@Tag(name = "相机测试")
public class CameraTestController {

    private final EquipmentFactory factory;
    private final FileProperties fileProperties;

    private String ip = "192.168.100.164";
    private String userName = "admin";
    private String password = "hbyt137258";
    private Integer port = 8000;
    /**
     * 抓图
     *
     * @return
     */
    @GetMapping(value = "startVoiceTransfer")
    public R startVoiceTransfer(@RequestParam(value = "cmd")int cmd) {
        IEquipmentService service =factory.getServiceByBrand("HK");
        QueryParamsDto queryParamsDto = new QueryParamsDto();
        queryParamsDto.setIp(ip);
        queryParamsDto.setUsername(userName);
        queryParamsDto.setPassword(password);
        queryParamsDto.setPort(port);
        queryParamsDto.setChannel(1);
        VoicePlayDto voicePlayDto = new VoicePlayDto();
        voicePlayDto.setPcmName(VoiceEnum.ONLINE.getName());
        service.executeCmd(queryParamsDto,true,EquipmentCmdEnum.VOICE_TRANSFER,voicePlayDto);
        return R.ok();
    }


}
